module.exports = (param) =>{
	var url = param.url;
	var method = param.method||'GET';
	var header = param.header||{};
	var data = param.data||{};
	
	// 获得保存的sessionID
	uni.getStorage({
		key: 'sessionId',
		success: function(res) {
			
		}
	})
	
	header = {
		"content-type":"application/json",
		'Accept': 'application/json',
		'session':'shadow-test'
	}
	
	// method：请求方式get或者post
	if(method){
		method = method.toUpperCase();
	}
	
	if(!param.hideLoading){
		uni.showLoading({title:"加载中……"});
	}
	
	// 发起网络请求
	uni.request({
		url:url,
		method:method||"GET",
		header:header,
		data:data,
		success:res=>{
			if(res.statusCode&&res.statusCode != 200){
				uni.showModal({
					content:res.msg
				})
				return;
			}
			typeof param.success == "function" && param.success(res);
		},
		
		fail:e=>{
			uni.showModal({
				content:e.msg
			})
			typeof param.fail == "function" && param.fail(e)
		},
		complete: e=>{
			uni.hideLoading();
			typeof param.complete == "function" && param.complete(e);
			return;
		}
	})
}